<?php include "antet.php"; include "func.php";

if (isset($_SESSION["user"][0]))
{
	$land=get_land();
	$xy=$land[rand(0, count($land)-1)];
	$towns=towns($_SESSION["user"][0]);
	$twnCount=count($towns);
	/*if(	$twnCount <= 0)
		{
			$is_cap=1;
		}
	else
		{
			$is_cap=0;
		}*/
		$is_cap=$_GET["is_cap"];
/*	if (!$towns)
	{
//		d($towns);
		$is_cap=$_GET["is_cap"];
		$data=explode("-", $towns[0][8]);
		$army=explode("-", $towns[0][7]);
		if ($data[7]<3) msg($lang['needCastle']);
		//if ($army[11]<3) msg($lang['needColonists']);
	}
	else
	{
		$is_cap=0;
	}*/
}
else {header('Location: login.php'); die();}
?>
<html>
<?php echo "<link rel='stylesheet' type='text/css' href='".$imgs.$fimgs."default.css'>"; ?>
<script src="func.js" type="text/javascript"></script>

<head>
<title><?php echo $title; ?> - <?php echo $lang['createTown'] ?></title>
</head>

<body class="q_body">
	
<div align="center"><?php echo $top_ad; ?>

<table class="q_table">
	<tr>
		<td class="td_logo"><?php logo($title); ?></td>
	</tr>
	<tr>
		<td class="td_top_menu"><?php menu_up(); ?></td>
	</tr>
	<tr>
		<td class="td_content"><?php

		echo "<br/>You can create unlimited number of towns but only 1 can become capital.";
		echo "<br/>The land must be explored first by you or others before it can be settled.";
		echo "<br/>Of course city and towns cannot be created in the sea.";
		echo "<br/>Terraforming is done automatically by your citizen.";
		echo "<br/>Have a good distance from other player cities for your and his empire growth.";
		echo "<br/><b>Changing capital will destroy the source and destination village, so choose the capital location wisely.</b>";
		echo "<br/>You can consult the <a class='btn btn-success' href='map.php?x=100&y=100'> map center</a> as starting point.";
		//echo "<br/>Only towns can become capital but it require more colonists.";
if($is_cap != 1)
{
		for ($i=0; $i<$twnCount; $i++)
		{
			$town=town_xy($towns[$i][0]);
			if ($towns[$i][4] == 1)
			{
				//$towns[$i][2]
				echo "<br/>You can consult the map using <a class='q_link' href='map.php?x=".$town[0]."&y=".$town[1]."'>".$towns[$i][2]." (".$town[0].", ".$town[1].")</a> as starting point.";
			}
		}
}
?>
<form name="form1" method="post"	action="create_.php?is_cap=<?php echo $is_cap; ?>">
		<p><?php echo $lang['desCoord'] ?>: <input class="textbox" name="x"
			id="x" type="text" size="5" value="<?php echo $xy[0]; ?>"> <input
			class="textbox" name="y" id="y" type="text" size="5"
			value="<?php echo $xy[1]; ?>"> [<a class='q_link' href="javascript: go('create.php?is_cap=<?php echo $is_cap; ?>');"><?php echo $lang['random'] ?></a>]
		</p>
		<p><?php echo $lang['desCapName'] ?>: 
		<input class="textbox" name="name" type="text" size="25" value="<?php echo $_SESSION["user"][1]; ?>"></p>
		<p>
		<input class="button" type="submit" name="go" value="<?php echo $lang['create'] ?>"></p>
		</form>
		</td>
	</tr>
	<tr>
		<td class="td_bottom_menu"><?php menu_down(); ?></td>
	</tr>
</table>

		<?php echo $bottom_ad; ?>
<p><?php about(); ?>

</div>

</body>

</html>
